package Com.Hupochuan.Uil.Do;

import Com.Hupochuan.Dal.Tab.PlayTab;
import Com.Hupochuan.Uil.Servlet.DoRunServlet;
import Com.Hupochuan.Uil.Util.MD5Util;
import Com.Hupochuan.Uil.Util.MemoryPond;
import Com.Hupochuan.Vo.Play;
import Com.Tester.Tester;

@SuppressWarnings("serial")
public class PlayDo extends DoRunServlet{
	public void doRun(){
		
		//打印测试
		Tester.print("打印测试 - PlayDo");
		
		//获得参数
		long playId = this.getDoTool().getLongPathPara(1);
		String ip = this.getDoTool().getIp();
		
		//获得数据
		Play play = MemoryPond.getObject().getPlay(playId);
		
		//没有找到此播放
		if(play == null){
			//发送错误
			this.getDoTool().sendError(404);
			return;
		}
		
		//获得防盗播放码
		String playCode = MD5Util.MD5(ip + "2014-11-17 15:11:48");
		
		//设置参数
		this.getDoTool().setAttr("play", play);
		this.getDoTool().setAttr("playCode", playCode);
		
		//转发页面
		this.getDoTool().doForward("/jsp/play.jsp");
		
		//获得html内容
		String htmlContent = this.getDoTool().htmlEncode(this.getDoTool().getContent());
		
		//发送信息
		this.getDoTool().sendMsg(htmlContent);
		
		//增加数据库里记录的播放次数
		PlayTab.getObject().updateDataAddPlayCount(playId);
	}
}
